import * as Cesium from 'cesium'
import h337 from 'heatmap.js-fixed/build/heatmap'

export const renderHeat = (viewer, dataSource) => {
  // 适配 Cesium 的热力图容器
  const CesiumHeat = h337.heatmap.cesiumAdapter(viewer, Cesium)
  const heat = new CesiumHeat({
    data: dataSource.map((point) => ({
      x: point.lng,
      y: point.lat,
      value: point.value,
    })),
    autoMaxMin: true,
    bounds: [114.03, 30.2, 114.45, 30.9],
  })
  return () => heat.destroy()
}
